<template>
    <div>
        <el-button type="primary" @click="router.go(-1)">返回</el-button>
    </div>
    <div>
        <el-upload 
            class="upload-demo" 
            drag :action="url" 
            multiple method="post"
            :on-success="handleAvatarSuccess"
        >
            <el-icon class="el-icon--upload"><upload-filled /></el-icon>
            <div class="el-upload__text">
                把文件放到这里或 <em>点击上传</em>
            </div>
        </el-upload>
    </div>
    <img src="https://hunshadock.oss-cn-beijing.aliyuncs.com/2-1719904636978.jpg"/>
</template>
<script setup lang="ts">
import { useRouter, useRoute } from 'vue-router'
import { UploadFilled } from '@element-plus/icons-vue'
import { ref, onMounted, reactive } from 'vue'
import axios from 'axios';
const router = useRouter();
const route = useRoute();

let item=reactive({})
// url
let url = ref('http://localhost:3000/web/upload')
onMounted(()=>{
    // getitem()
})

let handleAvatarSuccess=(item:any)=>{
    let pic=item.pic
    let _id=route.query._id
    let name=route.query.name
    
    let data={
        pic,
        _id,
        name
    }
    axios.post('http://localhost:3000/web/addimg',data).then((res)=>{
        console.log(res)
    })
}

</script>
<style scoped></style>